package com.woniuxy.shiro.mapper;

import com.woniuxy.shiro.entity.Role;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Repository;

import java.util.List;

@Mapper
@Repository
public interface RoleMapper {
    //通过用户id去role、user_role做连表查询
    @Select("select * from user_role ur,role r where ur.rid=r.id and ur.uid = #{uid}")
    @Results({
            @Result(id = true,column = "rid",property = "id"),
            @Result(column = "rid",property = "perms"
                    ,many = @Many(select = "com.woniuxy.shiro.mapper.PermMapper.findPermsByRid"))
    })
    public List<Role> findRolesByUid(int uid);
}
